//
import { defineStore } from 'pinia'
import { storage } from '../utils'
export default defineStore('currentViewsStore', {
  state: () => ({
    currentViews: {} as any,
  }),
  actions: {
    loadState() {
      const data = storage.get('CURRENT_VIEWS', '[]');
      this.$patch({ currentViews: JSON.parse(data) });
    },

    setAllState(newState: Partial<any>) {
      storage.set('CURRENT_VIEWS', JSON.stringify(newState))
      this.$patch({ currentViews: newState });
    },
    getAllState(): any {
      this.loadState();
      return this.currentViews;
    },
  },
})
